var keyIsNum = true;
function inputOnlyNum(myEvent)
{
    var keys=myEvent.keyCode;
    if (!((keys>=48&&keys<=57)||(keys>=96&&keys<=105)||( keys==8 )||(keys==46)||(keys==37)||(keys==39)||(keys==13)||(keys==229)
))
    {
       keyIsNum = false;
    }
    else
    {
       keyIsNum = true;
    }

}
function checkIfNum(myEvent)
{
    if(!keyIsNum)
    {
      if(document.all)
           myEvent.returnValue=false;//ie
      else
           myEvent.preventDefault();//ff
    }

}
function TextValidate()
{
    var code;
    var character;
    var err_msg = "Text can not contain SPACES or any of these special characters other than underscore (_) and hyphen (-).";
    if (document.all) //判断是否是IE浏览器
    {
        code = window.event.keyCode;
    }
    else
    {
        code = arguments.callee.caller.arguments[0].which;
    }
    var character = String.fromCharCode(code);
   
    var txt=new RegExp("[ ,\\`,\\~,\\!,\\@,\#,\\$,\\%,\\^,\\+,\\*,\\&,\\\\,\\/,\\?,\\|,\\:,\\<,\\>,\\{,\\},\\(,\\),\\',\\;,\\=,\"]");
    //特殊字符正则表达式
    if (txt.test(character))
    {
    	showmessage("禁止输入特殊符号，如： ` ~ ! @ # $ % ^ + & * \\ / ? | : < > {} () [] ","F");
        if (document.all)
        {
            window.event.returnValue = false;
        }
        else
        {
            arguments.callee.caller.arguments[0].preventDefault();
        }
    }
}
function checkEmail(email){
	var emailRegExp =/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
	if (!emailRegExp.test(email)){
	return false;
	}else{
	return true;
	}
}
function checkuserbymail(webpath,mail,umail,mailmessage){
	var flag=false;
	if(checkEmail(mail)){
		flag=true;
	}else{
		$(mailmessage).css('display','block');
		$(mailmessage).html('请填写正确的邮箱');
	}
	if(umail!=""){
		if(mail!=umail){
			flag=true;
		}else{
			flag=false;
		}
	}
	if(flag){
	var path=webpath+'users/isexitmail?mail='+encodeURI(mail)+'&r='+Math.round(Math.random()*10000);
	$.ajax({     	   
	    	url:path,
	    	async:false,
	        success:function(data){
	        	if(data == '1'){
	        		$(mailmessage).css('display','block');
	        		$(mailmessage).html('邮箱已经注册过');
	      			return false;
	      		}else{
	      			$(mailmessage).css('display','none');
	      		}
	        }       
	     });
	}
}
function checkpricekeyup(obj,e)
{
//	$(obj).keyup(function (event) {
//	    var keycode = event.which;
//	        alert(keycode);     
//	 });
	//obj.value=obj.value.replace(/[^\d\.]/g,'');

	var value=obj.value;
    var key = window.event?e.keyCode:e.which;
    if( (key > 95 && key < 106) ||
        (key > 47 && key < 60) ||
        (key == 110 && value.indexOf(".") < 0 )||
        (key == 190 && value.indexOf(".") < 0 ) ||
        (key == 173 && value.indexOf("-") < 0 ) ||
        (key == 189 && value.indexOf("-") < 0 ) ||
        (key == 190 && value.indexOf(".") < 0 ) ||
        (key == 37 || key == 39)){
    }else if(key !=8){
        if (window.event) //IE
        {
            e.returnValue = false;   //event.returnValue=false 效果相同.
        }
        else //Firefox
        {
            e.preventDefault();
        }
    }
}
function checkpricekeyup2(obj,e)
{
	var value=obj.value;
    var key = window.event?e.keyCode:e.which;
    if( (key > 95 && key < 106) ||
        (key > 47 && key < 60) ||
        (key == 37 || key == 39)){
    }else if(key !=8){
        if (window.event) //IE
        {
            e.returnValue = false;   //event.returnValue=false 效果相同.
        }
        else //Firefox
        {
            e.preventDefault();
        }
    }
}
function showdiv(title,id,w,h)
{
	$.XYTipsWindow({
		___title:title,
		___content:"id:"+id,
		___width:w,
		___height:h,
		___showbg:true
	});	
}
function closediv()
{
	$('.___closeBox').click();
}

function checkpricekeyupfs(obj,e)
{
	//obj.value=obj.value.replace(/[^\d\.]/g,'');

	var value=obj.value;

    var key = window.event?e.keyCode:e.which;
    if( (key > 95 && key < 106) ||
        (key > 47 && key < 60) ||
        (key == 110 && value.indexOf(".") < 0 ) ||
        (key == 190 && value.indexOf(".") < 0 ) ||
        (key == 173 && value.indexOf("-") < 0 ) ||
        (key == 189 && value.indexOf("-") < 0 ) ||
        (key == 109 && value.indexOf("-") < 0 ) ||
        (key == 37 || key == 39)){
    }else if(key !=8){
        if (window.event) //IE
        {
            e.returnValue = false;   //event.returnValue=false 效果相同.
        }
        else //Firefox
        {
            e.preventDefault();
        }
    }
}